package org.gd.hellojavacore.tests;

import java.util.Random;
import java.util.StringTokenizer;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author Gorhover
 * @version 1.0-SNAPSHOT
 * @since 2013-10-11 08:43
 */
public class UUIDTest {

    public static void main(String[] args) {

        int newValue = (int) ((((double)15)/100) * 70);
        System.out.println(newValue);

        AtomicInteger count = new AtomicInteger(10);
        for(;count.getAndDecrement()>0;) {
            String random = UUID.randomUUID().toString();
            System.out.printf("%d) String: %s (length: %d)\n",
                    count.get(), random, random.length());
        }
        System.out.println();

        String fullName = "Magazine Kapusta".trim();
        StringTokenizer tokenizer = new StringTokenizer(fullName);
        StringBuilder builder = new StringBuilder("TB_");
        while (tokenizer.hasMoreElements()) {
            builder.append(tokenizer.nextToken().trim().substring(0, 3));
        }
        if(builder.length() > 10) {
            builder = new StringBuilder(builder.toString().substring(0, 10));
        }


        String uuid = UUID.randomUUID().toString().replace("-", "");
        System.out.printf("uuid: %s (length: %d)\n",
                uuid, uuid.length());

        String newName = builder.append(uuid).toString().substring(0, 15);
        System.out.printf("String: %s (length: %d)\n",
                newName, newName.length());




    }
}
